package com.example.teemoproject;

import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class BackgroundManager {

	private ArrayList<GameViewBackground> backgrounds1 = new ArrayList<GameViewBackground>();

	private ArrayList<GameViewBackground> backgrounds2 = new ArrayList<GameViewBackground>();

	int stage = 1;

	public void add(Bitmap bitmap, int count, int index, int scrollSpeed,
			int stage) {

		if (stage == 1)
			backgrounds1.add(new GameViewBackground(bitmap, count, index,
					scrollSpeed));
		if (stage == 2)
			backgrounds2.add(new GameViewBackground(bitmap, count, index,
					scrollSpeed));
	}

	public void add(GameViewBackground background, int stage) {
		if (stage == 1)
			backgrounds1.add(background);
		if (stage == 2)
			backgrounds2.add(background);
	}

	public void update() {
		if (stage == 1)
			for (GameViewBackground background : backgrounds1) {
				background.update();
			}
		if (stage == 2)
			for (GameViewBackground background : backgrounds2) {
				background.update();
			}
	}

	public void doDraw(Canvas canvas) {
		if (stage == 1)
			for (GameViewBackground background : backgrounds1) {
				background.doDraw(canvas);
			}
		if (stage == 2)
			for (GameViewBackground background : backgrounds2) {
				background.doDraw(canvas);
			}
	}

	public void destroy() {

		for (GameViewBackground background : backgrounds1) {
			background.destroy();
		}

		for (GameViewBackground background : backgrounds2) {
			background.destroy();
		}
	}

}
